//
//  InfoViewController.m
//  homeland
//
//  Created by rain on 14-5-25.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "InfoViewController.h"
#import "MKNetworkKit.h"

@interface InfoViewController ()
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UITextView *contentTextView;
@end

@implementation InfoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"详情";
    self.titleLabel.text = @"";
    self.contentTextView.text = @"";
    NSString *url = [NSString stringWithFormat:@"%@%@",self.url,self.serverId];
    MKNetworkEngine *currentEngine = [[MKNetworkEngine alloc] initWithHostName:url customHeaderFields:nil];
    MKNetworkOperation *op = [currentEngine operationWithPath:@"" params:nil httpMethod:@"POST"];
    [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        
        NSDictionary *json = [completedOperation responseJSON];
//        [self.datas removeAllObjects];
//        NSArray *array = [completedOperation responseJSON];
//        [self.datas addObjectsFromArray:array];
//        [self.tableView reloadData];
        self.titleLabel.text = json[@"title"];
        self.contentTextView.text = json[@"detail"];
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        
    }];
    [currentEngine enqueueOperation:op];

    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
